//
//  ModifyPWDViewController.m
//  YunDongGym
//
//  Created by lqq on 2018/4/18.
//  Copyright © 2018年 lqq. All rights reserved.
//

#import "ModifyPWDViewController.h"
#import "I_Account.h"
@interface ModifyPWDViewController ()
@property (weak, nonatomic) IBOutlet UITextField *originPWDTextField;
@property (weak, nonatomic) IBOutlet UITextField *freshPWDTextField;
@property (weak, nonatomic) IBOutlet UIButton *saveBtn;
@property (weak, nonatomic) IBOutlet UITableViewCell *fisrtCell;

@end

@implementation ModifyPWDViewController

#pragma mark Class Method
+ (instancetype)controller
{
    ModifyPWDViewController *modifyPWDVC = [UIStoryboard controllerWithStoryBoardIdentify:NSStringFromClass([ModifyPWDViewController class]) inStoryBoard:@"Service"];
    return modifyPWDVC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"修改密码";
    self.tableView.insetTop = 10;
    _saveBtn.layer.cornerRadius = 2;
    _saveBtn.layer.masksToBounds = YES;
    [_fisrtCell.contentView addBottomLineViewWithLeftSpace:0 rightSpace:0];
    
}
- (IBAction)saveBtnClicked:(id)sender {
    NSString *oldPwd = _originPWDTextField.text;
    NSString *newPwd = _freshPWDTextField.text;
    
    if (oldPwd.length < 6) {
        [AV showRemind:@"请输入正确的原密码"];
        return;
    }
    if (newPwd.length < 6) {
        [AV showRemind:@"新密码太短"];
        return;
    }
    [AV showLoading:@"请稍后"];
    WeakSelf(self);
    [I_Account modifyPWDWithOldPWD:oldPwd newPwd:newPwd success:^{
        [AV showSuccess:@"修改成功"];
        [weakself.navigationController popViewControllerAnimated:YES];
    } failure:^(NSError *error) {
        [AV showError:error];
    }];
}

@end
